<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page language="java" import="net.sf.rose.business.bean.base.Group" %>
<%@ page language="java" import="java.util.List" %>
<%@include file="/common/header.jsp"%>
<c:set var="path" value="..${ctx}/define/judge"/>

<form id="define_judge_list" method="post" action="${path}/list.html">
<input type="hidden" id="js_judge_list_back_function" name="js_judge_list_back_function" value="${jsbackfn}" />
</form>

<div id="resultBox"></div>

	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="add" onclick="return addjudge();" title="添加判断"><span>添加</span></a><br /><br /></li>
			<li class="line">line</li>
			<li><a class="edit" onclick="return editjudge();" title="修改判断"><span>修改</span></a></li>
			<li class="line">line</li>
			<li><a class="delete" onclick="return deletejudge();" title="确定要删除吗?"><span>删除</span></a></li>
			<li class="line">line</li>
			<li><a class="add" onclick="return backjudge();" title="结束返回"><span>返回</span></a></li>
		</ul>
	</div>

	<table class="table" width="100%" layoutH="138">
		<thead>
			<tr>
				<th width="80">分类</th>
				<th width="240">描述</th>
			</tr>

		</thead>
			<tbody>
			<c:if test="${! empty list.judges}">
			<c:forEach var="data" items="${list.judges}">
			<tr target="params" rel="${data.id}" class="base_define_judge_list_tr">
				<td>${data.typeString}</td>
				<td>${data.description}</td>
			</tr>
			</c:forEach>
			</c:if>
		</tbody>
	</table>

<script type="text/javascript">

function addjudge(action){
	var title = "添加判断";
	var url = "${path}/add.html";
	$.pdialog.open(url, "base_define_judge_add", title,{width:600,height:460,mask:true,maxable:false,resizable:false});
}

function editjudge(){
	var rel = '';
	$('.base_define_judge_list_tr').each(function(){
		if($(this).hasClass("selected")){
			rel = $(this).attr('rel');
		}
	});
	if(rel==''){
		alertMsg.warn('请先选择一条数据！');
	}else{
		var title = "更新判断";
		var url = "${path}/edit.html?id=" + rel;
		$.pdialog.open(url, "base_define_judge_add", title,{width:600,height:460,mask:true,maxable:false,resizable:false});
	}
}

function deletejudge(){
	var rel = '';
	$('.base_define_judge_list_tr').each(function(){
		if($(this).hasClass("selected")){
			rel = $(this).attr('rel');
		}
	});
	if(rel==''){
		alertMsg.warn('请先选择一条数据！');
	}else{
		alertMsg.confirm("确定要删除吗?", {
			okCall: function(){
				var url = "${path}/delete.html?id=" + rel;
				$.ajax({
					type: "post", url: url,
					success: function(json){
						alertMsg.correct(json.msg);
						var url = "${path}/list.html";
						$.pdialog.reload(url);
					},
					error: function(){
						alertMsg.error('系统错误，请联系管理员！');
					}
				});
			}
		});
	}
}

function backjudge(){
	var funname = $("input[name='js_judge_list_back_function']").val();
	var fun = eval(funname);
	new fun();
	$.pdialog.closeCurrent();
}

</script>


